import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;

import '../Robot.dart';
import '../details.dart';
import '../pojo.dart';

class  CommodityViewModel2 extends ChangeNotifier{
  Commodity? commodity;
  Future<void> getProductById(String id) async {
    var url = Uri.https(host, 'product/commodity/getById');
    var response = await http.post(url, body: {'access_token': Robot.accessToken,'id':id});
    print("getProductById:"+response.body);
    var a = ApiResponse<Commodity>.fromJson(jsonDecode(response.body),  (data) => Commodity.fromJson(data));
    print("getProductById: "+a.data.toString());
    print("getProductById: "+a.data!.name!);
    notifyListeners();
    commodity = a.data;
    return;
  }
}